W4. Regular Language Closure
1. Theory
1.1 Representations of Finite State Automata
In previous lectures, we learned the formal definition of a Finite State Automaton (FSA). Now we explore two important variations in how the transition function can be defined: complete and incomplete FSAs.
1.1.1 Complete FSAs
A complete FSA is one where the transition function
This means that no matter what state the automaton is in and what symbol it reads, there is always a defined transition to some state (which could be the same state via a self-loop).
Why is completeness important? A complete FSA guarantees that every string over the alphabet can be processed without getting “stuck.” The automaton will always have a well-defined final state, which is either accepting or rejecting.
Example: Consider an FSA over alphabet
- From
: on input 0 → stay in , on input 1 → go to - From
: on input 0 → go to , on input 1 → stay in
This is complete because every combination
1.1.2 Incomplete FSAs
An incomplete FSA (also called a partial FSA) is one where the transition function
What happens when we reach an undefined transition? When processing a string, if the FSA encounters a situation where
Example: Consider an FSA over alphabet
(start) → on ‘a’ go to ; on ‘b’ undefined (accept) → on ‘b’ stay in ; on ‘a’ undefined
This FSA accepts strings matching the pattern “a” followed by zero or more ‘b’s (
Graphical Representation: In state diagrams, incomplete FSAs simply omit arrows for undefined transitions. Complete FSAs show all possible transitions.
1.1.3 Converting Incomplete FSAs to Complete FSAs
Any incomplete FSA can be converted to an equivalent complete FSA by adding a trap state (also called an error state or sink state). The process is:
- Add a new non-accepting state
(or for “error”) - For every undefined transition
, define it to go to the trap state: - Add self-loops on the trap state for all symbols:
for all
The trap state has a special property: once entered, the automaton can never leave. Since it’s non-accepting, any string that leads to it will be rejected.
Example: Converting the incomplete FSA from above:
- Add
(non-accepting) on ‘b’ → on ‘a’ → on ‘a’ → on ‘b’ →
Now every state-symbol combination has a defined transition, making the FSA complete while preserving the language it recognizes.
1.2 Regular Languages
A regular language is any language that can be recognized (accepted) by a finite state automaton. This is a fundamental concept in theoretical computer science.
Formal Definition: A language
Here,
Important Properties of Regular Languages:
- Decidability: For any regular language
and any string , we can algorithmically determine whether by simulating the FSA - Finiteness of description: Regular languages can be described by FSAs with finitely many states
- Closure properties: Regular languages are closed under many operations (union, intersection, complement, concatenation, Kleene star)
Examples of Regular Languages:
(regular) (regular) (NOT regular—requires counting, which FSAs cannot do)
1.3 Operations on Finite State Automata
One of the most powerful properties of regular languages is that they are closed under various operations. This means that if we apply these operations to regular languages, the result is still a regular language. We can construct FSAs for the resulting languages using systematic methods.
1.3.1 Complement
Problem: Given an FSA
Key Idea: To accept the opposite language, we “flip” the accepting and non-accepting states. A string previously accepted should now be rejected, and vice versa.
Construction for Complete FSAs:
Given a complete FSA
where
Everything stays the same except the accepting states are flipped.
Example: Consider an FSA over
: , with (accepts strings with odd length) : Same transitions, but (accepts strings with even length, including )
Why Does This Work? In a complete FSA, every string leads to some final state. If that state was accepting in
Critical Requirement: Completeness
The simple “flip accepting states” approach only works for complete FSAs. Why?
In an incomplete FSA, some strings cause undefined transitions and are implicitly rejected (they don’t reach any state). When we flip accepting states, we’re only changing what happens to strings that DO complete processing. We’re not addressing strings that were rejected due to undefined transitions.
Construction for Incomplete FSAs:
To construct the complement of an incomplete FSA:
- First, make the FSA complete by adding a trap state for all undefined transitions
- Then, flip the accepting states:
Example: Incomplete FSA:
Step 1: Add trap state
on ‘b’ → on ‘a’ → on ‘a’, ‘b’ →
Step 2: Flip accepting states. Original
The complement FSA accepts all strings except those starting with ‘a’ and continuing with only ’b’s.
1.3.2 Intersection
Problem: Given two FSAs
Key Idea: We run both FSAs in parallel on the same input. We accept a string only if it would be accepted by BOTH individual FSAs.
Construction (Product Construction):
Given:
The intersection automaton is:
where:
(Cartesian product: pairs of states) (pair of initial states) (transition in both simultaneously) (BOTH must be accepting)
Intuition: Each state
Example:
- States:
- Transitions:
, - Accepting:
- States:
- Transitions:
- Accepting:
Product automaton
- States:
- Transitions:
, - Accepting:
(where and )
This accepts strings with odd number of symbols (same as
Size: If
1.3.3 Union
Problem: Given two FSAs
Construction:
The construction is almost identical to intersection, except for the accepting states:
where:
(EITHER can be accepting)
The only difference from intersection is the accepting condition: We use logical OR (
Example: Using the same
- Accepting states:
(since , both states qualify) - The initial state
is accepting, so even is accepted - This accepts all strings (same as
)
Alternative Construction Using De Morgan’s Laws:
We can also construct union using complement and intersection:
This means: “NOT (NOT
1.3.4 Difference
Problem: Given two FSAs
Construction:
Again using the product construction:
where:
(in AND not in )
Intuition: We accept only when “
Example:
(nothing is in but not in , since is everything)- Accepting:
(no state satisfies , since and all reachable states have )
Reversed Example:
- Accepting:
(where and ) - This accepts even-length strings (including
)
1.4 Finite State Transducers
A Finite State Transducer (FST) extends the concept of a finite state automaton by adding an output capability. While an FSA only accepts or rejects strings, an FST transforms input strings into output strings.
1.4.1 Formal Definition
A Finite State Transducer is a tuple:
where:
is a standard FSA (the “acceptance” component) is the output alphabet (a finite set of symbols for output) is the output function that maps each transition to a string of output symbols (possibly empty)
Key Points:
- Translation is performed only on accepted strings: If the input string is not accepted by the underlying FSA, no output is produced (or the transducer fails)
- Each transition can produce output: When transitioning from state
on input , the transducer outputs - Output can be empty (
): Some transitions produce no output
Graphical Representation: In diagrams, transitions are labeled as
1.4.2 Example: Removing Odd Occurrences of 0 and Doubling 1s
Problem: Build an FST over alphabet
- Accepts strings with an even number of 0’s
- Outputs a transformed string where:
- Every odd occurrence of 0 is removed (outputs
) - Every even occurrence of 0 is kept (outputs 0)
- Every 1 is doubled (outputs 11)
- Every odd occurrence of 0 is removed (outputs
Examples:
- Input: “010010” → Output: “110110”
- 0 (1st, odd) →
- 1 → 11
- 0 (2nd, even) → 0
- 0 (3rd, odd) →
- 1 → 11
- 0 (4th, even) → 0
- 0 (1st, odd) →
- Input: “00” → Output: “0”
- 0 (1st, odd) →
- 0 (2nd, even) → 0
- 0 (1st, odd) →
- Input: “000100011” → Output: “011001111”
- 0 (odd) →
, 0 (even) → 0, 0 (odd) → , 1 → 11, 0 (even) → 0, 0 (odd) → , 0 (even) → 0, 1 → 11, 1 → 11
- 0 (odd) →
FST Construction:
- States:
(accepting): “Seen an even number of 0’s” : “Seen an odd number of 0’s”
- Transitions and Outputs:
(loop: reading 1, output 11, stay in even state) (reading 1st/3rd/… 0, output nothing, go to odd state) (loop: reading 1, output 11, stay in odd state) (reading 2nd/4th/… 0, output 0, return to even state)
- Accepting states:
(even number of 0’s)
How it works: The transducer tracks parity (even/odd count) of 0’s using states. Each transition specifies what to output. For 1’s, output is always “11”. For 0’s, output depends on whether it’s an odd occurrence (
1.4.3 Applications of FSTs
FSTs are used in many practical applications:
- Text processing: Find-and-replace operations, spell correction
- Natural language processing: Morphological analysis (e.g., converting “walked” to “walk”)
- Compilers: Translating source code patterns to target code
- Data compression: Encoding/decoding schemes
- Regular expression replacement: Implementing operations like
s/pattern/replacement/g
1.5 Closure Properties of Regular Languages
A family of languages
What does closure mean intuitively? Think of a set being “closed” like a closed system in physics—no matter what operations you perform inside the system, you never leave it. For languages, if you start with regular languages and apply certain operations, you get back regular languages.
Regular languages are closed under:
- Union:
is regular (proven by product construction) - Intersection:
is regular (proven by product construction) - Complement:
is regular (proven by flipping accepting states in complete FSA) - Difference:
is regular (proven by product construction) - Concatenation:
is regular - Kleene star:
is regular
Why is closure important?
- Compositional reasoning: We can build complex regular languages from simpler ones
- Proving regularity: If we know
and are regular, we immediately know is regular without constructing an FSA - Compiler design: Combining patterns to recognize complex tokens
Example: The language
is regular is regular is regular (by closure under union)
1.6 Practical Considerations: Simplifying FSAs
When constructing FSAs using operations like intersection or union, the resulting automaton may have unreachable states—states that cannot be reached from the initial state. These can be removed without changing the language.
Example: In the product construction, if
Simplification algorithm:
- Mark the initial state as reachable
- Iteratively mark states reachable from already-marked states via any transition
- Remove all unmarked states and their transitions
This process is important for practical implementation, as it reduces the size and complexity of the automaton.
2. Definitions
- Complete FSA: A finite state automaton where the transition function
is total, meaning is defined for every state and every symbol . - Incomplete FSA (Partial FSA): A finite state automaton where the transition function is partial, meaning some combinations of state and input symbol have no defined transition. Strings reaching undefined transitions are automatically rejected.
- Trap State (Error State, Sink State): A non-accepting state added to an incomplete FSA to make it complete. All undefined transitions lead to the trap state, which has self-loops for all input symbols, ensuring that once entered, the automaton remains there and rejects the string.
- Regular Language: A language
that can be recognized (accepted) by some finite state automaton. Equivalently, is regular if there exists an FSA such that . - Complement of a Language: For a language
over alphabet , the complement (or ) is the set of all strings over that are not in : . - Intersection of Languages: For languages
and over the same alphabet, the intersection is the set of strings that belong to both languages: . - Union of Languages: For languages
and , the union is the set of strings that belong to at least one of the languages: . - Difference of Languages: For languages
and , the difference is the set of strings in but not in : . - Product Construction: A method for combining two FSAs
and into a single FSA whose states are pairs where and . The construction simulates running both automata in parallel on the same input. - Cartesian Product of Sets: For sets
and , the Cartesian product is the set of all ordered pairs. - Finite State Transducer (FST): An extension of a finite state automaton that produces output strings in addition to accepting or rejecting input. Formally defined as
where is the output alphabet and is the output function. - Output Function (
): In an FST, the function that specifies what output string (possibly empty) is produced when transitioning from a state on a given input symbol. - Closure Property: A family of languages
is closed under an operation if applying that operation to languages in produces another language in . Regular languages are closed under union, intersection, complement, difference, concatenation, and Kleene star. - Unreachable State: A state in an FSA that cannot be reached from the initial state by any sequence of transitions. Unreachable states can be removed without changing the language accepted by the FSA.
3. Formulas
- Complement FSA (Complete): For a complete FSA
, the complement is where - Intersection FSA (Product Construction): For
and , the intersection is where: - Union FSA (Product Construction): Same as intersection except
- Difference FSA (Product Construction): Same as intersection except
- De Morgan’s Laws for Languages:
and
4. Practice
4.1. Constructing an FST: Past Tense to Present Tense (Lab 4, Task 1)
Build a complete FST over alphabet
- Accepts only the verbs “walked” or “talked”
- Translates the input verb to present tense (removes the “ed”)
Click to see the solution
Key Concept: The FST reads the input character by character, outputting the appropriate transformation. For “walked” → “walk”, we output each letter except the final “ed”.
- Design the states:
(start): Haven’t seen anything yet : Seen “w” or “t” : Seen “wa” or “ta” : Seen “wal” or “tal” : Seen “walk” or “talk” : Seen “walke” or “talke” (accepting): Seen complete “walked” or “talked” : Error state for invalid inputs
- Define transitions and outputs:
- From
: on ‘w’ output ‘w’, go to ; on ‘t’ output ‘t’, go to ; else go to trap - From
: on ‘a’ output ‘a’, go to ; else go to trap - From
: on ‘l’ output ‘l’, go to ; else go to trap - From
: on ‘k’ output ‘k’, go to ; else go to trap - From
: on ‘e’ output , go to (don’t output ‘e’) - From
: on ‘d’ output , go to (don’t output ‘d’) is accepting- Trap state loops with no output
- From
Verification:
- Input: “walked” → Output: “w” + “a” + “l” + “k” +
+ = “walk” ✓ - Input: “talked” → Output: “t” + “a” + “l” + “k” +
+ = “talk” ✓
Answer: The FST has states
4.2. Constructing an FST: Erasing Every Second ‘a’ (Lab 4, Task 2)
Build a complete FST over alphabet
- Accepts only strings ending with the letter ‘b’
- Translates the input by erasing every second occurrence of ‘a’
Click to see the solution
Key Concept: Track the parity of ‘a’s seen so far. Output ’a’ on odd occurrences, erase (output
- Design states:
(start): Seen even number of ‘a’s, not ended with ’b’ : Seen odd number of ‘a’s, not ended with ’b’ (accepting): Seen even number of ‘a’s, ended with ’b’ (accepting): Seen odd number of ‘a’s, ended with ’b’
- Transitions and outputs:
- From
: on ‘a’ output ‘a’, go to (first ‘a’, odd count); on ‘b’ output ‘b’, go to - From
: on ‘a’ output , go to (second ‘a’, even count, erase); on ‘b’ output ‘b’, go to - From
: on ‘a’ output ‘a’, go to ; on ‘b’ output ‘b’, stay in - From
: on ‘a’ output , go to ; on ‘b’ output ‘b’, stay in
- From
- Accepting states:
(ended with ‘b’)
Verification:
- Input: “aaab” → Outputs: ‘a’ (1st ‘a’),
(2nd ‘a’), ‘a’ (3rd ‘a’), ‘b’ → “aab” ✓ - Input: “aabb” → Outputs: ‘a’,
, ‘b’, ‘b’ → “abb” ✓
Answer: The FST has four states tracking parity of ‘a’s and whether the string ends with ’b’, with outputs as described.
4.3. Building FSAs for Even 1’s and Odd 0’s (Lab 4, Task 3)
Let
Problem 1: Build a complete FSA
Problem 2: Build a complete FSA
Click to see the solution
Key Concept: Track parity (even/odd count) using two states. Reading the tracked symbol toggles the state.
(a) FSA for Even Number of 1’s (
- States:
(start, accepting): Even number of 1’s seen : Odd number of 1’s seen
- Transitions:
- From
: on ‘0’ stay in (0’s don’t affect count); on ‘1’ go to (even → odd) - From
: on ‘0’ stay in ; on ‘1’ go to (odd → even)
- From
- Accepting:
Verification:
- ““: in
→ ACCEPT (zero 1’s is even) ✓ - “11”:
→ ACCEPT ✓ - “101”:
→ ACCEPT ✓ - “1”:
→ REJECT ✓
(b) FSA for Odd Number of 0’s (
- States:
(start): Even number of 0’s seen (accepting): Odd number of 0’s seen
- Transitions:
- From
: on ‘1’ stay in ; on ‘0’ go to (even → odd) - From
: on ‘1’ stay in ; on ‘0’ go to (odd → even)
- From
- Accepting:
Answer:
has states with accepting has states with accepting
4.4. Combining FSAs: Union, Intersection, Difference (Lab 4, Task 4)
Using the FSAs
Problem 3: Build a complete FSA that accepts when EITHER
Problem 4: Build a complete FSA that accepts when BOTH
Problem 5: Build a complete FSA that accepts when
Problem 6: Build a complement for
Click to see the solution
Key Concept: Use product construction for all except complement. Accepting states differ based on the operation.
(Problem 3) Union:
- Product construction:
- Initial:
- Transitions:
- Accepting states (at least one component accepting):
Answer: The union FSA has 4 states with 3 accepting states:
(Problem 4) Intersection:
- Same product construction
- Accepting states (both components accepting):
Answer: The intersection FSA has 4 states with 1 accepting state:
(Problem 5) Difference:
- Same product construction
- Accepting states (
accepts, rejects):
Answer: The difference FSA has 4 states with 1 accepting state:
(Problem 6) Complement:
is already complete (has transitions for all inputs)- Flip accepting states: Original
Complement
Answer:
4.5. Complement of Incomplete FSA (Lab 4, Task 5)
Construct a complement for the following incomplete FSA over alphabet
(start, accepting): loops on ‘1’; goes to on ‘0’ : goes to on ‘0’; transition on ‘1’ is undefined
Click to see the solution
Key Concept: First complete the FSA, then flip accepting states.
- Add trap state
for undefined transitions: on ‘1’ → on ‘0’ → on ‘1’ → (self-loops)
- Complete FSA:
- States:
(accepting), - All transitions defined
- States:
- Flip accepting states: Original
Complement
Answer: The complement FSA has states
4.6. FSAs for Divisibility by 2 and 3 (Lab 4, Task 6)
Let
Problem 1: Build a complete FSA
Problem 2: Build a complete FSA
Click to see the solution
Key Concept: Divisibility can be determined by examining specific patterns in binary representation.
(a) Divisibility by 2:
A binary number is divisible by 2 if and only if its last digit is 0 (or it’s the empty string, representing 0).
- States:
(start, accepting): Last digit seen is 0, or no digits yet ( ) : Last digit seen is 1
- Transitions:
- From
: on ‘0’ stay in (last digit is 0); on ‘1’ go to (last digit is 1) - From
: on ‘0’ go to (last digit is 0); on ‘1’ stay in (last digit is 1)
- From
- Accepting:
Verification:
→ in → ACCEPT (represents 0, divisible by 2) ✓- “10” (= 2) →
→ ACCEPT ✓ - “11” (= 3) →
→ REJECT ✓
(b) Divisibility by 3:
We track the remainder when the number is divided by 3. Reading binary digits left-to-right, we update the remainder using:
States (represent remainder mod 3):
(start, accepting): Remainder is 0 (divisible by 3) : Remainder is 1 : Remainder is 2
Transitions: From state
, reading digit :- New state:
Explicitly:
- From
: on ‘0’ → ( ); on ‘1’ → ( ) - From
: on ‘0’ → ( ); on ‘1’ → ( ) - From
: on ‘0’ → ( ); on ‘1’ → ( )
- New state:
Accepting:
Verification:
→ in → ACCEPT (0 divisible by 3) ✓- “11” (= 3) →
→ ACCEPT ✓ - “110” (= 6) →
→ ACCEPT ✓ - “10” (= 2) →
→ REJECT ✓
Answer:
has 2 states, accepting when last digit is 0 has 3 states, accepting when remainder mod 3 is 0
4.7. Combining Divisibility FSAs (Lab 4, Task 7)
Using
Problem 3: Build a complete FSA that accepts when BOTH
Problem 4: Build a complete FSA that accepts when EITHER
Problem 5: Build a complete FSA that accepts when
Click to see the solution
Key Concept: Use product construction with appropriate accepting conditions.
(Problem 3) Divisible by 6:
- Product states:
states Initial: - Accepting (divisible by both 2 and 3):
Answer: The FSA for divisibility by 6 has 6 states with 1 accepting state:
(Problem 4) Divisible by 2 or 3:
- Same product states
- Accepting (divisible by 2 OR 3):
Answer: The FSA has 6 states with 4 accepting states.
(Problem 5) Divisible by 2 but not 3:
- Same product states
- Accepting (divisible by 2 AND NOT by 3):
Answer: The FSA has 6 states with 2 accepting states:
4.8. Complex Product Construction (Lab 4, Task 8)
Let
- States:
(start), , (accepting) - Transitions:
loops on ‘b’, goes to on ‘a’; loops on ‘a’, goes to on ‘b’; goes to on ‘b’
- States:
(start), , (accepting) - Transitions:
loops on ‘a’, goes to on ‘b’; goes to on ‘a’, goes to on ‘b’; loops on ‘a’ and ‘b’
Draw complete FSAs accepting:
(i)
Click to see the solution
Key Concept: Use product construction, then identify accepting states based on the operation.
(i) Union:
Product states:
states Initial:Accepting states (at least one component accepting):
Explicitly:
Transitions: Apply
for all states and symbols
Answer: 9-state FSA with 5 accepting states (all pairs where
(ii) Intersection:
- Same product construction
- Accepting states (both components accepting):
Answer: 9-state FSA with 1 accepting state:
(iii) Difference:
- Same product construction
- Accepting states (
accepts, rejects):
Answer: 9-state FSA with 2 accepting states:
4.9. Converting State Diagram to State Table (Tutorial 4, Example 1)
Given an FSA as a State Transition Diagram, build a State Transition Table.
The FSA has three states:
, , ,
Click to see the solution
Key Concept: A state transition table is an alternative representation of an FSA, showing transitions in tabular form. Rows represent states, columns represent input symbols, and entries show the destination state.
- Create the table structure:
- Rows: One for each state (
) - Columns: One for each symbol in the alphabet (
) - Mark the initial state with
and accepting states with
- Rows: One for each state (
- Fill in transitions from the diagram:
- From
: on ‘a’ go to , on ‘b’ go to - From
: on ‘a’ go to , on ‘b’ go to - From
: on ‘a’ go to , on ‘b’ go to
- From
State Transition Table:
| a | b | |
|---|---|---|
Answer: The completed state transition table is shown above.
4.10. Completing an Incomplete FSA (Tutorial 4, Example 2)
Given an incomplete FSA over alphabet
(start) (accepting) (accepting) (self-loop)
Transitions on ‘b’ from
Click to see the solution
Key Concept: To complete an FSA, add a trap state and define all missing transitions to lead to it.
- Identify undefined transitions:
is undefined is undefined
- Add a trap state
(non-accepting) - Define the missing transitions to go to the trap:
- Add self-loops on the trap state for all symbols:
Complete FSA:
- States:
(start), (accepting), (trap, non-accepting) - Transitions:
, , ,
Answer: The completed FSA includes a trap state
4.11. Complement of a Complete FSA (Tutorial 4, Example 3)
Given a complete FSA
This FSA accepts strings with an odd number of ’a’s. Construct
Click to see the solution
Key Concept: For a complete FSA, the complement is obtained by flipping accepting and non-accepting states.
- Identify the original accepting states:
- Compute the complement set:
- Construct the complement FSA:
Everything is the same except
Verification:
- Original
accepts: “a”, “aaa”, “aaaaa”, … (odd lengths) - Complement
accepts: , “aa”, “aaaa”, … (even lengths, including zero)
Answer:
4.12. Complement of an Incomplete FSA (Tutorial 4, Example 4)
Given an incomplete FSA over alphabet
(start) (accepting) (self-loop)
Construct the complement FSA.
Click to see the solution
Key Concept: For incomplete FSAs, we must first make them complete before computing the complement.
- Make the FSA complete by adding a trap state:
- Add state
(trap) (was undefined) (was undefined) , (self-loops)
- Add state
- The complete FSA has:
- States:
- Accepting states:
- States:
- Compute the complement:
Complement FSA:
- States:
(start, accepting), (non-accepting), (accepting) - Same transitions as the completed version
- Accepting states:
Answer: The complement FSA accepts all strings except those of the form
4.13. Intersection of Two FSAs (Tutorial 4, Example 5)
Given:
where , (accepts odd-length strings) where (accepts all strings)
Construct
Click to see the solution
Key Concept: Use the product construction with accepting states being pairs where both components are accepting.
- Determine the product states:
- Determine the initial state:
- Define transitions using
: - Determine accepting states (both components must be accepting):
Product FSA:
where:
Answer: The intersection FSA accepts strings with odd length (same as
4.14. Intersection of Complex FSAs (Tutorial 4, Example 6)
Given two FSAs over alphabet
- States:
(start), , (accepting), - Transitions:
, ; , ; loops on ; loops on
- States:
(start), , (accepting) - Transitions:
, ; , ; loops on
Construct
Click to see the solution
Key Concept: Use product construction, then identify and remove unreachable states.
Build the full product automaton:
- States:
states total - Initial state:
- Accepting states:
- States:
Determine transitions for all pairs: For example:
- From
on ‘a’: - From
on ‘b’: - From
on ‘a’: — this leads to the accepting state!
- From
Identify reachable states from
:To reach
in : must go To reach in : must go (and loops on all symbols)Path for “aaba”:
✓Simplified automaton (after removing unreachable states):
Answer: The simplified intersection FSA accepts strings that reach both
4.15. Union of Two FSAs (Tutorial 4, Example 7)
Using the same
Click to see the solution
Key Concept: Use product construction with accepting states being pairs where at least one component is accepting.
Product states and transitions are the same as for intersection:
- Initial:
- Transitions:
Determine accepting states (at least one component accepting):
Since
and all reachable states have , we have for all states.Therefore:
(both states are accepting)Result: Since the initial state
is accepting, even the empty string is accepted. In fact, every string is accepted.
Answer:
4.16. Difference of Two FSAs (Tutorial 4, Example 8)
Compute
Click to see the solution
Key Concept: Accepting states are pairs where the first component is accepting and the second is NOT accepting.
- Product construction (same states and transitions as before):
- Initial:
- Determine accepting states:
- For
: ✓ but ✗ (we need ) - For
: ✗ - Result:
(no accepting states)
Answer:
4.17. Difference of Two FSAs (Tutorial 4, Example 9)
Compute
Click to see the solution
- Accepting states:
- We need:
AND - For
: ✓ and ✓ → accepting - For
: ✓ but ✗ → not accepting - Result:
- We need:
Answer: